<div class="tableinfo">
    <div class="tableHeader">
        <p>Xem Tin Nhắn</p>
    </div>
    
    
    <table border ="0" cellspacing ="0" cellpadding ="0">


        
        <?php
            $trangthaitn = $_SESSION['tinnhan'];
            $idtinnhan = $_GET['id']; 
            if($trangthaitn=="tinnhan"){
            $sql = "SELECT TieuDe,NoiDung,id_NhanVien,date_format(ngaygoi,'%d/%m/%Y')as ngaygoi FROM  tinnhangui WHERE id=$idtinnhan";
            $sql2="UPDATE  tinnhangui SET MaTTTN_nguoinhan =  '2' WHERE id =$idtinnhan AND  NhanVienNhan =  '$user'";
            $dstinnhan = executeQuery($sql);
            executeQuery($sql2);            
            
            while ($row = mysql_fetch_assoc($dstinnhan)){
               
            echo " <tr><td style='background: silver; color: yellow'><b>".$row['TieuDe']." - Người gởi: ".$row['id_NhanVien']." - Ngày: ".$row['ngaygoi']."</b></td> </tr> <tr><td>".$row['NoiDung']."</td></tr>" ;

            }
            }else{
            $sql = "SELECT TieuDe,NoiDung,NhanVienNhan,date_format(ngaygoi,'%d/%m/%Y')as ngaygoi FROM  tinnhangui WHERE id=$idtinnhan";
            $sql2="UPDATE  tinnhangui SET MaTTTN =  '2' WHERE id =$idtinnhan AND  id_NhanVien =  '$user'";
            $dstinnhan = executeQuery($sql);
            executeQuery($sql2);            
            
            while ($row = mysql_fetch_assoc($dstinnhan)){
               
            echo " <tr><td style='background: silver; color: yellow'><b>".$row['TieuDe']." - Người nhận: ".$row['NhanVienNhan']." - Ngày: ".$row['ngaygoi']."</b></td> </tr> <tr><td>".$row['NoiDung']."</td></tr>" ;                
            }
            }
        ?>
    </table>

     
</div>
